<%@ page contentType="text/html;charset=UTF-8" language="java"  import="java.util.*" trimDirectiveWhitespaces="true" %>
<%@include file="/WEB-INF/pages/common/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
  <title>今日金价管理</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <%@include file="/WEB-INF/pages/common/commonCss.jsp"%>
  <link rel="stylesheet" href="${basePath}/resources/css/uniform.css" />
  <link rel="stylesheet" href="${basePath}/resources/css/select2.css" />
  <link rel="stylesheet" href="${basePath}/resources/css/matrix-style.css" />
  <link rel="stylesheet" href="${basePath}/resources/css/matrix-media.css" />
  <link rel="stylesheet" href="${basePath}/resources/css/admin/list.css" />
</head>

<body>

<!--Header-part-->
<%@include file="/WEB-INF/pages/common/head.jsp"%>


<!--sidebar-menu-->
<%@include file="/WEB-INF/pages/common/left.jsp"%>

<div id="content">
  <div id="content-header">
    <div id="breadcrumb"> <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 首页</a> <a href="#" class="current">今日金价管理</a> </div>
  </div>

  <div class="container-fluid">
    <br>
    <p>目前的抓取规则:每2小时抓取一次,如果浮动范围超过5%，会显示异常状态</p>
  </div>

  <div class="container-fluid">

    <hr>
    <div class="row-fluid">
      <div class="span12">


        <div class="widget-box">
          <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <h5 style="padding: 4px;">
              <%--<a href="#myModal"  class="btn btn-primary" data-toggle="modal"><i class="icon-plus" style="padding-right: 0.2rem"></i>新增</a>--%>
              <a  onclick="dayprice.add()" class="btn btn-primary" ><i class="icon-plus" style="padding-right: 0.2rem"></i>重新抓取</a>
            </h5>
            <a style="float: right;margin-top: 0.2rem" onclick="tzAdmin.search()" class="btn btn-success"><i class="icon-search icon-white"></i></a>

            <label style="float: right;margin-top: 0.2rem">
              <input type="text" id="keywords" aria-controls="DataTables_Table_0" placeholder="输入查询关键字">
            </label>

          </div>
          <div class="widget-content nopadding">
            <table class="table table-bordered data-table">
              <thead>

              <tr>
                <th>主键</th>
                <th>品类 <span class="up"></span> <span class="down"></span></th>
                <th>价格</th>
                <th>是否异常</th>
                <th>创建时间</th>
                <th>操作</th>
              </tr>
              </thead>
              <tbody id="tbody" data-model="service/dayprice">
                  <tr>
                    <td id="loading" colspan="50"></td>
                  </tr>


              </tbody>
               <tfoot>

               </tfoot>
            </table>
            <div class="cpage"></div>

          </div>
        </div>
      </div>
    </div>
  </div>
</div>


<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
          &times;
        </button>
        <h4 class="modal-title" id="myModalLabel">当前价格</h4>
      </div>
      <div class="modal-body">
        <p>请输入(单位:￥) <input type="text" id="nowPrice"  style="height: 2rem;" value="" placeholder="请输入价格"></p>
        <input type="hidden" id="daypriceId">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
        </button>
        <button type="button" class="btn btn-primary"  onclick="dayprice.update(this)">
        提交更改
        </button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal -->
</div>

   <!--Footer-part-->
<%@include file="/WEB-INF/pages/common/footer.jsp"%>

<!--end-Footer-part-->

<%@include file="/WEB-INF/pages/common/commonJS.jsp"%>
<script type="text/javascript" src="${basePath}/resources/sg/tz_page.js"></script>
<script src="${basePath}/resources/js/jquery.ui.custom.js"></script>
<script src="${basePath}/resources/js/bootstrap.min.js"></script>
<script src="${basePath}/resources/js/jquery.uniform.js"></script>
<script src="${basePath}/resources/js/select2.min.js"></script>
<script src="${basePath}/resources/js/jquery.dataTables.min.js"></script>
<script src="${basePath}/resources/js/matrix.js"></script>
<%--<script src="${basePath}/resources/js/matrix.tables.js"></script>--%>

   <script>
       $(function(){
         tzAdmin.loadData(0,10,function(itemCount){
           tzAdmin.initPage(itemCount);//分页加载一次吗
         });
       });

       var dayprice = {
           add:function(){
              $.ajax({
                  url:adminPath+"/service/dayprice/add",
                  beforeSend:loading("数据抓取中..."),
                  type:"post",
                  success:function(data) {
                      console.log('====='+JSON.stringify(data));
                      if(data == "success"){
                         window.location.href = window.location.href;
                      }
                  }
              });
           },
           edit:function (obj ,id ,price ,name) {
               $("#myModalLabel").html("当前"+name+"价格");
               $("#nowPrice").val(price);
               $("#daypriceId").val(id);
               $('#myModal').modal('show');
           },
           update:function (obj) {
               var id =  $("#daypriceId").val();
               var price = $("#nowPrice").val();
               var data ={id:id,price:price};
               console.log("data=="+JSON.stringify(data));
               $.ajax({
                   url:adminPath + "/service/dayprice/update",
                   type:"post",
                   data:data,
                   success:function (data) {
                      if(data==1){
                          $('#myModal').modal('hide')
                          window.location.href = window.location.href;
                      }
                   }
               });
           }
       };

   </script>

</body>
</html>
